import time

from celery import Celery


"""
celery_test: celery_name
broker:消息中间件
backend:结果的存储
"""
app = Celery(
    'celery_test',
    broker='redis://127.0.0.1:6379/1',
    backend='redis://127.0.0.1:6379/2')


@app.task
def hello(name):
    time.sleep(4)
    print('hello world, {name}!'.format(name=name))
    return 'hello world, {name}!'.format(name=name)


@app.task
def my_task(a, b):
    print(a + b)
    return a + b
